/**
 * Created by rik on 14-11-14.
 */
exports.sidebar = {
    init : function() {
        var id = location.pathname.substr(location.pathname.lastIndexOf('/') + 1);
        $el = $('#sidebar').find('#' + id);
        $el.parent().addClass('active');
        $el.addClass('active');
        $el.parent().prev().addClass('active');

        $('#sidebar').find('.title').bind('click', function (event) {
            var me = $(this);
            $('#sidebar').find('.title').each(function (i) {
                var $tmp = $('#sidebar').find('.title').eq(i);
                if (me != $tmp) {
                    $tmp.removeClass('active');
                    $tmp.next().removeClass('active');
                }
            });
            $(this).toggleClass('active');
            $(this).next().toggleClass('active');
        })
    }
}